package com.example.demo.service;

import com.example.demo.dao.ShopDAO;
import com.example.demo.dao.UserDAO;
import com.example.demo.entity.Goods;
import com.example.demo.entity.Result;
import com.example.demo.entity.Shop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Service
public class ShopService {

    @Autowired
    private ShopDAO shopDAO;

    public List<Shop> findShops()
    {
        return shopDAO.findShops();
    }

    public Shop findShop(Goods goods)
    {
        return shopDAO.findShop(goods);
    }

    public List<Shop> listShopsBySearchMsg(String searchMsg, int currentPage){
        int start = (currentPage-1)*10;
        return shopDAO.listShopBySearchMsg(searchMsg,start);
    }

    public int listShopsBySearchMsgTotal(String searchMsg){
        int total = shopDAO.listShopBySearchMsgTotal(searchMsg);
        return shopDAO.listShopBySearchMsgTotal(searchMsg);
    }

    public void editShop(Shop shop){
        shopDAO.editShop(shop);
    }

    public void deleteShopById(int id){
        shopDAO.deleteShop(id);
    }

    public void addShop(Shop shop){
        shopDAO.addShop(shop);
    }
}
